import resolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import babel from "@rollup/plugin-babel";
import { uglify } from "rollup-plugin-uglify";
import { name } from "./package.json";
import commonjs from "@rollup/plugin-commonjs";

const config = {
  input: "./src/index.js",
  output: {
    file:
      "dist/" + name + (process.env.NODE_ENV === "dev" ? "" : ".min") + ".js",
    format: "umd",
    name: "$Focus",
    sourcemap: false,
  },
  plugins: [
    resolve(),
    json(),
    commonjs(),
    babel({
      exclude: "node_modules/**",
      extensions: [".js"],
      babelHelpers: "runtime",
    }),
  ],
};

if (process.env.NODE_ENV === "prod") {
  config.plugins.push(uglify());
}
export default config;
